//
//  ThreeBtnSectionView.m
//  WGFGlobalHouses
//
//  Created by Andy on 15/7/13.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//

#import "ThreeBtnSectionView.h"
#import "config.h"


@interface ThreeBtnSectionView ()
@property (strong, nonatomic)  UILabel *redLine;

@end


@implementation ThreeBtnSectionView
@synthesize redLine;



+(instancetype)creatView{
    
    ThreeBtnSectionView *view = [[[NSBundle mainBundle]loadNibNamed:@"ThreeBtnSectionView" owner:nil options:nil]lastObject];

    view.redLine = [[UILabel alloc]initWithFrame:CGRectMake(0, view.frame.size.height-2, 80, 2)];
    view.redLine.center = CGPointMake(view.btn1.center.x, view.redLine.frame.origin.y);
    [view.redLine setBackgroundColor:[UIColor redColor]];
    [view addSubview:view.redLine];
    
    return view;
}


- (IBAction)btn1OnClick:(id)sender {
    
    [self.btn1 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [self.btn2 setTitleColor:UIColorFromRGB(0X333333) forState:UIControlStateNormal];
    [self.btn3 setTitleColor:UIColorFromRGB(0X333333) forState:UIControlStateNormal];
    

    [UIView  beginAnimations:@"ANI" context:nil];
    
    CGPoint buf = CGPointMake(self.btn1.center.x, self.redLine.center.y);
    [self.redLine setCenter:buf];
    
    [UIView commitAnimations];

}


- (IBAction)btn2OnClick:(id)sender {
    
    
    [self.btn1 setTitleColor:UIColorFromRGB(0X333333) forState:UIControlStateNormal];
    [self.btn2 setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [self.btn3 setTitleColor:UIColorFromRGB(0X333333) forState:UIControlStateNormal];
    
    
    [UIView  beginAnimations:@"ANI" context:nil];
    
    CGPoint buf = CGPointMake(self.btn2.center.x, self.redLine.center.y);
    [self.redLine setCenter:buf];
    
    [UIView commitAnimations];

}

- (IBAction)btn3OnClick:(id)sender {
    
    
    [self.btn1 setTitleColor:UIColorFromRGB(0X333333) forState:UIControlStateNormal];
    [self.btn2 setTitleColor:UIColorFromRGB(0X333333) forState:UIControlStateNormal];
    [self.btn3 setTitleColor:[UIColor redColor]  forState:UIControlStateNormal];
    

    [UIView  beginAnimations:@"ANI" context:nil];
    
    CGPoint buf = CGPointMake(self.btn3.center.x, self.redLine.center.y);
    [self.redLine setCenter:buf];
    
    [UIView commitAnimations];
    
}


@end
